<template>
	<view>
		<view class="con">
			<view class="title">金蜜券数量</view>
			<view class="box" :style="uid==0?'':'height:220rpx'">
				<view class="input">
					<input type="text" v-model="value" />
					<image src="../static/jingyan5.png" class="unit"></image>
				</view>
				<view class="rmb">剩余金蜜券 <text>{{jindou}}</text> </view>
				<view class="button" v-if="uid==0" @click="sour_but">
					<image src="../static/jingyan4.png"></image>
					查询兑换人
				</view>
			</view>
			<view class="title" style="margin-top: 80rpx;">派发人信息</view>
			<view class="box2" v-if="info.uid!=''">
				<image :src="getHead(info.head_image)"></image>
				<view class="con1">
					<view class="item1">{{info.nickname}}</view>
					<view class="item2">{{info.telphone}}</view>
				</view>
			</view>
		</view>
		<view class="sub_button" @click="sub">确认派发</view>
		<u-popup v-model="show" :closeable="true" borderRadius="10" mode="bottom">
			<view class="harvest">
				<view class="title">
					选择派发人
				</view>
				<view class="list" @click="cuid=item.uid,i=index" v-for="(item,index) in list" :key="index">
					<image class="icon" :src="cuid==item.uid?'../static/xx1.png':'../static/xx2.png'" mode=""></image>
					<image :src="getHead(item.head_image)" class="head"></image>
					<view class="user">
						<view class="name">
							{{item.nickname}}
						</view>
						<view class="text">
							{{item.telphone}}
						</view>
					</view>
				</view>
				<button type="default" class="button2" @click="show=false,info=list[i]">确认选择</button>
			</view>
		</u-popup>
	</view>
</template>

<script>
	var than;
	export default {
		data() {
			return {
				show: false,
				value: 0,
				img_url: '../static/exchange_tb2.png',
				info: {
					uid: "",
					head_image: "",
					nickname: "",
					telphone: ""
				},
				discount: [],
				uid: 0,
				jindou: 0,
				list: [],
				cuid: 0,
				i: 0
			}
		},
		onLoad(option) {
			than = this;
			if (option.uid) {
				than.uid = option.uid;
				than.post("operate/goldbean/findTeamDetails", {
					uid: than.uid
				}, function(data) {
					than.info = data;
				})
			}
			than.getList();
		},
		onReachBottom() {
			than.page++
			than.getList();
		},
		methods: {
			sour_but() {
				than.show = true;
			},
			getList() {
				than.post("operate/Goldbean/gdbDetails", {
					page: than.page
				}, function(data) {
					than.jindou = data.allcount;
					if (than.page == 1) {
						than.list = data.list;
					} else {
						than.list = than.list.concat(data.list)
					}
				})
			},
			sub() {
				if (!than.info.uid) {
					than.toast("请获取兑换人")
					return false
				}
				than.post("operate/Goldbean/handOutGdbTicket", {
					number: than.value,
					uid: than.info.uid
				}, function(data) {
					than.toast(data)
					setTimeout(function() {
						uni.navigateBack();
					}, 1500);
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background: white;
	}

	.harvest {
		text-align: center;
		padding-bottom: 54rpx;

		.title {

			height: 114rpx;
			line-height: 114rpx;
			font-size: 38rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #333333;
		}

		.list {
			display: flex;
			align-items: center;
			height: 98rpx;
			padding: 0 24rpx;

			.icon {
				width: 36rpx;
				height: 36rpx;
				margin-right: 22rpx;
			}

			.head {
				width: 98rpx;
				height: 98rpx;
				margin-right: 12rpx;
			}

			.user {
				text-align: left;

				.name {
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
					margin-bottom: 15rpx;
				}

				.tel {
					font-size: 24rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #999999;
				}
			}
		}



		.button2 {
			margin: 20rpx auto 0;
			width: 314rpx;
			height: 80rpx;
			background: #333333;
			box-shadow: 0px 6rpx 8rpx 0px rgba(170, 170, 170, 0.16);
			border-radius: 40rpx;
			font-size: 32rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: #FFFFFF;
			line-height: 80rpx;
		}

	}

	.content {
		border-radius: 20rpx;
		margin-top: 28rpx;

		.up {
			height: 54rpx;
			background: #FEC31D;
			display: flex;
			align-items: center;
			border-radius: 20rpx 20rpx 0px 0px;

			.list {
				width: 50%;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #FFFFFF;
				padding-left: 30rpx;
			}
		}

		.down {
			background: #F7F6F4;
			display: flex;
			align-items: center;
			height: 64rpx;
			border-bottom: 2rpx solid #FFFFFF;

			.list {
				width: 50%;
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #F46813;
				padding-left: 30rpx;
			}

			.l {
				border-right: 2rpx solid #FFFFFF;
			}
		}
	}

	.con {
		padding: 40rpx 36rpx 36rpx 36rpx;

		.title {
			font-size: 36rpx;
			font-weight: bold;
			color: #333333;
		}

		.box {
			height: 280rpx;
			padding: 23rpx;
			background: #F4F4F7;
			border-radius: 20rpx;
			margin-top: 20rpx;

			.head {
				font-size: 32rpx;
				font-weight: bold;
				border-radius: 50%;
				color: #333333;
				margin-top: 15rpx;
			}

			.input {
				display: flex;
				align-items: center;
				border-bottom: 2rpx solid #FFFFFF;
				padding: 16rpx 0rpx;

				input {
					font-size: 60rpx;
					font-weight: bold;
					height: 80rpx;
					font-family: myFirstFont;
				}

				.unit {
					width: 58rpx;
					height: 37rpx;
				}
			}

			.rmb {
				font-size: 24rpx;
				font-weight: bold;
				padding: 20rpx 0rpx;

				text {
					color: #F46813;
					margin-left: 20rpx;
				}
			}

			.button {
				display: flex;
				align-items: center;
				width: 314rpx;
				height: 105rpx;
				background: #FEC31D;
				box-shadow: 0px 3px 16px 4px rgba(148, 146, 146, 0.12);
				border-radius: 20rpx;
				font-size: 32rpx;
				font-weight: bold;
				color: #FFFFFF;
				margin: 20rpx auto 0;
				justify-content: center;

				image {
					width: 36rpx;
					height: 36rpx;
					margin-right: 20rpx;
					margin-top: 7rpx;
				}
			}
		}

		.box2 {
			padding: 37rpx 24rpx;
			background-color: #F4F4F7;
			border-radius: 20rpx;
			display: flex;
			align-items: center;
			margin-top: 20rpx;

			image {
				width: 98rpx;
				height: 98rpx;
				border-radius: 50%;
				margin-right: 20rpx;
			}

			.con1 {
				flex: 1;

				.item1 {
					font-size: 28rpx;
					font-weight: bold;
					color: #333333;
				}

				.item2 {
					font-size: 40rpx;
					font-weight: bold;
					color: #F46813;
					font-style: italic;
					font-family: myFirstFont;
					margin-top: 10rpx;
				}
			}
		}

		.box3 {
			font-size: 26rpx;
			font-weight: 500;
			color: #333333;
			line-height: 36rpx;
			padding: 40rpx 0rpx;
		}


		.box4 {
			font-size: 24rpx;
			font-weight: 500;
			color: #999999;
			line-height: 36rpx;
			margin-top: 60rpx;
		}
	}

	.sub_button {
		position: fixed;
		bottom: 71rpx;
		left: 0;
		right: 0;
		margin: auto;
		width: 474rpx;
		height: 80rpx;
		line-height: 80rpx;
		background: #333333;
		box-shadow: 0rpx 6rpx 8rpx 0rpx rgba(170, 170, 170, 0.16);
		border-radius: 40rpx;
		text-align: center;
		font-size: 32rpx;
		font-weight: bold;
		color: #FFFFFF;
	}
</style>
